﻿// Copyright (c)  MOKEYISH. All rights reserved.
// Licensed under the MIT License, See License.txt in the project root for license information.

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;

namespace NSQL.TypeMapping
{
    [SuppressMessage("ReSharper", "InconsistentNaming")]
    public class OracleTypeMaps
    {
        private static readonly List<TypeMap> List = new List<TypeMap>();
        public static readonly IReadOnlyList<TypeMap> Types = List.AsReadOnly();

        public static readonly TypeMap Varchar2 = NewType("VARCHAR2", new[] {DbType.String}, new[] {typeof(string)},
            DbType.String);

        public static readonly TypeMap NVarchar2 = NewType("NVARCHAR2", new[] {DbType.StringFixedLength},
            new[] {typeof(string)},
            DbType.StringFixedLength);

        public static readonly TypeMap Date = NewType("DATE", new[] {DbType.Date}, new[] {typeof(DateTime)},
            DbType.Date);

        public static readonly TypeMap Char = NewType("CHAR", new[] {DbType.String}, new[] {typeof(string)},
            DbType.String);

        public static readonly TypeMap Float = NewType("FLOAT", new[] {DbType.Single}, new[] {typeof(float)},
            DbType.Single);

        public static readonly TypeMap Integer = NewType("INTEGER", new[] {DbType.Int32, DbType.Int64},
            new[] {typeof(int), typeof(long)}, DbType.Int64);

        public static readonly TypeMap Number = NewType("NUMBER", new[] {DbType.Double, DbType.Single},
            new[] {typeof(double), typeof(float)}, DbType.Double);

        public static readonly TypeMap Int = NewType("INT", new[] {DbType.Int16}, new[] {typeof(short)}, DbType.Int16);

        public static readonly TypeMap Number1_0 =
            NewType("NUMBER(1,0)", new[] {DbType.Int16}, new[] {typeof(short)}, DbType.Int16);

        public static readonly TypeMap Number2_0 =
            NewType("NUMBER(2,0)", new[] {DbType.Int16}, new[] {typeof(short)}, DbType.Int16);

        public static readonly TypeMap Number3_0 =
            NewType("NUMBER(3,0)", new[] {DbType.Int16}, new[] {typeof(short)}, DbType.Int16);

        public static readonly TypeMap Number4_0 =
            NewType("NUMBER(4,0)", new[] {DbType.Int16}, new[] {typeof(short)}, DbType.Int16);

        public static readonly TypeMap Number5_0 =
            NewType("NUMBER(5,0)", new[] {DbType.Int16}, new[] {typeof(short)}, DbType.Int16);

        public static readonly TypeMap Number6_0 =
            NewType("NUMBER(6,0)", new[] {DbType.Int32}, new[] {typeof(int)}, DbType.Int32);

        public static readonly TypeMap Number7_0 =
            NewType("NUMBER(7,0)", new[] {DbType.Int32}, new[] {typeof(int)}, DbType.Int32);

        public static readonly TypeMap Number8_0 =
            NewType("NUMBER(8,0)", new[] {DbType.Int32}, new[] {typeof(int)}, DbType.Int32);

        public static readonly TypeMap Number9_0 =
            NewType("NUMBER(9,0)", new[] {DbType.Int32}, new[] {typeof(int)}, DbType.Int32);

        public static readonly TypeMap Number10_0 =
            NewType("NUMBER(10,0)", new[] {DbType.Int32}, new[] {typeof(int)}, DbType.Int32);


        public static readonly TypeMap Number11_0 =
            NewType("NUMBER(11,0)", new[] {DbType.Int64}, new[] {typeof(long)}, DbType.Int64);

        public static readonly TypeMap Number12_0 =
            NewType("NUMBER(12,0)", new[] {DbType.Int64}, new[] {typeof(long)}, DbType.Int64);

        public static readonly TypeMap Number13_0 =
            NewType("NUMBER(13,0)", new[] {DbType.Int64}, new[] {typeof(long)}, DbType.Int64);

        public static readonly TypeMap Number14_0 =
            NewType("NUMBER(14,0)", new[] {DbType.Int64}, new[] {typeof(long)}, DbType.Int64);

        public static readonly TypeMap Number15_0 =
            NewType("NUMBER(15,0)", new[] {DbType.Int64}, new[] {typeof(long)}, DbType.Int64);

        public static readonly TypeMap Number16_0 =
            NewType("NUMBER(16,0)", new[] {DbType.Int64}, new[] {typeof(long)}, DbType.Int64);

        public static readonly TypeMap Number17_0 =
            NewType("NUMBER(17,0)", new[] {DbType.Int64}, new[] {typeof(long)}, DbType.Int64);

        public static readonly TypeMap Number18_0 =
            NewType("NUMBER(18,0)", new[] {DbType.Int64}, new[] {typeof(long)}, DbType.Int64);

        public static readonly TypeMap Number19_0 =
            NewType("NUMBER(19,0)", new[] {DbType.Int64}, new[] {typeof(long)}, DbType.Int64);


        public static readonly TypeMap RAW16 = NewType("RAW(16)", new[] {DbType.Guid}, new[] {typeof(Guid)},
            DbType.Guid);

        public static readonly TypeMap Smallint = NewType("SMALLINT", new[] {DbType.Int16}, new[] {typeof(short)},
            DbType.Int16);

        public static readonly TypeMap Timestamp =
            NewType("TIMESTAMP", new[] {DbType.DateTime}, new[] {typeof(DateTime)}, DbType.DateTime);


        private static TypeMap NewType(string typeName, DbType[] dbTypes, Type[] clrTypes, DbType? inferredDbType)
        {
            var t = new TypeMap(typeName, dbTypes, clrTypes, inferredDbType);
            List.Add(t);
            return t;
        }
    }
}